/**
 * col_enum
 */
layui.define(['YunjColsTemplet','jquery','yunj'], function (exports) {

    let YunjColsTemplet = layui.YunjColsTemplet;
    let doc = document;
    let $ = layui.jquery;

    class YunjColsTempletEnum extends YunjColsTemplet{

        constructor(options) {
            super(options);
        }

        layout(){
            let that=this;
            return `{{# 
                        let options = JSON.parse('${JSON.stringify(that.args.options)}');
                        let vals = d.${that.key};
                        vals = yunj.isArray(vals)?vals:(yunj.isJson(vals)?JSON.parse(vals):[vals]);
                        let text = "";
                        for(let i=0,l=vals.length;i<l;i++){
                            let val = vals[i];
                            if(options.hasOwnProperty(val)) text+='、'+options[val];
                        }
                        text = text?text.substr(1):text;
                     }}
                     <div class="table-row-enum" title="点击复制">{{ text }}</div>`;
        }

        defineExtraEventBind(){
            let that=this;

            $(doc).on('click','.table-row-enum',function () {
                yunj.copy($(this).html());
            });
        }

    }

    exports('col_enum', YunjColsTempletEnum);
});